home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Online / CNetDemo / cnet / sdk / Examples / SubListVars.c < prev    next >
Encoding:
Text File  |  1997-09-04  |  28.0 KB  |  772 lines

  1. /************************************************************************
  2.  *    CNet/3 and CNet/4  C language interface routines and examples     *
  3.  *                                                                      *
  4.  *  copyright © 1996 ZenMetal Software ... this code may be freely      *
  5.  *  distributed to and used by registered CNet owners EXCLUSIVELY.      *
  6.  *  Other distribution is in violation of copyright laws.               *
  7.  ************************************************************************/
  8.  
  9.  
  10.  
  11. /************************************************************************
  12.  *                          Function prototypes                         *
  13.  ************************************************************************/
  14. void        CallHost( UBYTE c );
  15. void        ShutDown( char *spawn );
  16. void        GetOut( void );
  17. void        LoadError( void );
  18. BOOL        IsAbort( void );
  19.  
  20.  
  21. /************************************************************************
  22.  *                           Global Variables                           *
  23.  ************************************************************************/
  24. struct MsgPort         *replyp;    /* Some communication details ...    */
  25. struct CPort           *cport;
  26. struct CMessage        cmess;
  27. struct MainPort        *myp;        /* Pointer to CNet port--ALL info!    */
  28. struct PortData        *z;
  29. char                     **bm;
  30. struct Library         *CNetBase = NULL;
  31. struct SignalSemaphore *SEM;
  32.  
  33.  
  34.  
  35. /************************************************************************
  36.  *                             Main routine                             *
  37.  ************************************************************************/
  38. void main( int argc, char **argv )
  39. {
  40.     LONG zzz=0;
  41.  
  42.     Forbid();
  43.     if(argc > 1) cport = (struct CPort *)FindPort( argv[1] );
  44.     Permit();
  45.  
  46.     if( argc<2 || !(cport) ) {
  47.         printf("This is a CNet C program.\n");
  48.         exit(0);
  49.         }
  50.  
  51.     if( !(replyp = CreatePort( 0,0 )))
  52.         exit(0);
  53.  
  54.     cmess.cn_Message.mn_ReplyPort   = replyp;
  55.     cmess.cn_Message.mn_Length      = sizeof( struct CMessage );
  56.     cmess.cn_Message.mn_Node.ln_Name= "cstuff";
  57.  
  58.     // CNet version check
  59.     if( cport->ack != 30 ) {
  60.         cport->ack = 1;
  61.         LoadError();
  62.         }
  63.  
  64.     cport->ack = 0;
  65.  
  66.     z    = cport->zp;
  67.     myp  = cport->myp;
  68.     SEM  = myp->SEM;
  69.     bm   = z->bm;
  70.  
  71.     if( !(CNetBase = OpenLibrary( "cnet.library", 4 )) ) // <- NOTE version 4 - can be changed to 3 to make compatible with older CNet releases!
  72.         LoadError();
  73.  
  74. /************************************************************************
  75.  *           End of CNet setup - YOUR CUSTOM CODE STARTS HERE           *
  76.  ************************************************************************/
  77.  
  78.     for( zzz=0 ; (zzz<myp->ns) && IsAbort() ; zzz++ )
  79.         {
  80.         // print subboard info!
  81.         sprintf(z->ABuffer, "\nTITLE        : %su0\n", myp->Subboard[zzz].Title);
  82.         PutA();
  83.         sprintf(z->ABuffer, "SubDirName   : %s\n", myp->Subboard[zzz].SubDirName);
  84.         PutA();
  85.         sprintf(z->ABuffer, "DataPath     : %s\n", myp->Subboard[zzz].DataPath);
  86.         PutA();
  87.         sprintf(z->ABuffer, "Parts        : %ld\n", myp->Subboard[zzz].Parts);
  88.         PutA();
  89.         sprintf(z->ABuffer, "Filler       : %s\n", myp->Subboard[zzz].Filler);
  90.         PutA();
  91.         sprintf(z->ABuffer, "Direct       : %d\n", myp->Subboard[zzz].Direct);
  92.         PutA();
  93.         sprintf(z->ABuffer, "FreeDays     : %d\n", myp->Subboard[zzz].FreeDays);
  94.         PutA();
  95.         sprintf(z->ABuffer, "SubDirectory : %d\n", myp->Subboard[zzz].Subdirectory);
  96.         PutA();
  97.         sprintf(z->ABuffer, "Closed       : %d\n", myp->Subboard[zzz].Closed);
  98.         PutA();
  99.         sprintf(z->ABuffer, "Union Flags  : %d\n", myp->Subboard[zzz].UnionFlags);
  100.         PutA();
  101.         sprintf(z->ABuffer, "Access       : %d\n", myp->Subboard[zzz].Access);
  102.         PutA();
  103.         sprintf(z->ABuffer, "Post Access  : %d\n", myp->Subboard[zzz].PostAccess);
  104.         PutA();
  105.         sprintf(z->ABuffer, "RespondAccess: %d\n", myp->Subboard[zzz].RespondAccess);
  106.         PutA();
  107.         sprintf(z->ABuffer, "Upload Access: %d\n", myp->Subboard[zzz].UploadAccess);
  108.         PutA();
  109.         sprintf(z->ABuffer, "DLoad Access : %d\n", myp->Subboard[zzz].DownloadAccess);
  110.         PutA();
  111.         sprintf(z->ABuffer, "Comp Types   : %d\n", myp->Subboard[zzz].ComputerTypes);
  112.         PutA();
  113.         sprintf(z->ABuffer, "Zero Path    : %s\n", myp->Subboard[zzz].ZeroPath);
  114.         PutA();
  115.         sprintf(z->ABuffer, "Origin       : %s\n", myp->Subboard[zzz].Origin);
  116.         PutA();
  117.         sprintf(z->ABuffer, "Max Items    : %d\n", myp->Subboard[zzz].MaxItems);
  118.         PutA();
  119.         sprintf(z->ABuffer, "nm           : %d\n", myp->Subboard[zzz].nm);
  120.         PutA();
  121.         sprintf(z->ABuffer, "rn           : %d\n", myp->Subboard[zzz].rn);
  122.         PutA();
  123.         sprintf(z->ABuffer, "AllocItems   : %d\n", myp->Subboard[zzz].AllocItems);
  124.         PutA();
  125.         sprintf(z->ABuffer, "nNewMess     : %d\n", myp->Subboard[zzz].nNewMess);
  126.         PutA();
  127.         }
  128.  
  129.  
  130.     /* exit back to CNet - always call GetOut() to exit back to CNet! */
  131.     GetOut();
  132. }
  133.  
  134.  
  135. /**************************************************************************
  136.  *       Routine called if Load error (wrong CNet version, etc,...        *
  137.  **************************************************************************/
  138. void LoadError( void )
  139. {
  140.     DeletePort( replyp );
  141.     exit(0);
  142. }
  143.  
  144. /************************************************************************
  145.  *                           Generic EXIT code                          *
  146.  ************************************************************************/
  147. void GetOut( void )
  148. {
  149.     ShutDown( NULL );
  150.     DeletePort( replyp );
  151.     exit(0);
  152. }
  153.  
  154.  
  155. /**************************************************************************
  156.  *                         another file to run?                           *
  157.  **************************************************************************/
  158. void ShutDown( char *spawn )
  159. {
  160.     /* spawn = full path/file to run */
  161.     if( spawn )
  162.         strcpy( z->CSpawn, spawn );
  163.  
  164.     CallHost( 0 );
  165. }
  166.  
  167.  
  168. void CallHost( UBYTE c )
  169. {
  170.     cmess.command = c;
  171.     PutMsg  ( (struct MsgPort *)cport, (struct Message *)&cmess );
  172.     WaitPort( replyp );
  173.     GetMsg  ( replyp );
  174. }
  175.  
  176. void PutText( char *text )
  177. {
  178.     cmess.arg1 = (ULONG)text;    /* text to print        */
  179.     CallHost( 1 );
  180. }
  181.  
  182. void PutA( void )
  183. {
  184.     PutText( z->ABuffer );
  185. }
  186.  
  187.  
  188. /**************************************************************************
  189.  *    ENTERLINE FLAGS:                                                    *
  190.  *    Construct by ORing the following bit defines:                       *
  191.  *                                                                        *
  192.  * ie. EnterLine(3, ELINE_ALLCAPS|ELINE_INPOUTBOX, "My Prompt>");         *
  193.  *                                                                        *
  194.  *     FLAGS:                                                             *
  195.  *     ------                                                             *
  196.  *     ELINE_ALLCAPS       = All capitalized                              *
  197.  *     ELINE_FILENAME      = FILENAME.  Don't allow =":; or asterisk      *
  198.  *     ELINE_USEINBUFF     = Begin with existing z.InBuffer               *
  199.  *     ELINE_NOLEADSPACE   = Chop leading spaces                          *
  200.  *     ELINE_CAPWORDSTART  = Force 1st letter of word caps                *
  201.  *     ELINE_RESTWORDLOWER = Force all others lower case                  *
  202.  *     ELINE_NUMBERSONLY   = Numeric input only                           *
  203.  *     ELINE_INPUTBOX      = Print input box (terminated with . )         *
  204.  *     ELINE_ALLOWMCI      = DO allow MCI                                 *
  205.  *     ELINE_HANDLESPECIAL = HANDLES/SPECIAL.  Don't allow ^_`{|}~@       *
  206.  *     ELINE_XSLASHSTART   = Exit for . or / at beginning of line         *
  207.  *     ELINE_XBKSPACESTART = Exit for backspace at beginning of line      *
  208.  *     ELINE_NOOLMS        = Do not allow OLM's to appear while editing   *
  209.  *     ELINE_ALLOWCHAT     = Allow Chat break in at this prompt. COMMAND  *
  210.  *                           PROMPT.                                      *
  211.  *     ELINE_NOSPACES      = Don't allow SPACES                           *
  212.  *     ELINE_NOCURSORMOVE  = DON'T ALLOW MOVEMENT                         *
  213.  *     ELINE_NOSLASHES     = Don't allow forward slash                    *
  214.  *                                                                        *
  215.  *  NOTE: The old "numeric" flag values still work 100% ..                *
  216.  **************************************************************************/
  217. int EnterLine( UBYTE len, ULONG flags, char *prompt )
  218. {
  219.     cmess.arg1 = (ULONG)len;     /* how many chars max to input    */
  220.     cmess.arg2 = (ULONG)flags;   /* flags describing required input handling */
  221.     cmess.arg3 = (ULONG)prompt;  /* text to print before input    */
  222.     CallHost( 2 );               /* result is in z->InBuffer    */
  223.  
  224.     return( (int)strlen( z->InBuffer ));
  225. }
  226.  
  227.  
  228. /**************************************************************************
  229.  *                       Stop until a key is pressed                      *
  230.  **************************************************************************/
  231. char OneKey( void )
  232. {
  233.     CallHost( 3 );
  234.     return( (char)cmess.result );    /* function returns ASCII value of key pressed */
  235. }
  236.  
  237.  
  238. /**************************************************************************
  239.  *
  240.  **************************************************************************/
  241. void EnterPassword( UBYTE len )
  242. {
  243.     cmess.arg1 = (ULONG)len;    /* max number of characters */
  244.     CallHost( 4 );
  245. }
  246.  
  247. /**************************************************************************
  248.  *                 Check z->InBuffer for Chat, OLM, etc                   *
  249.  **************************************************************************/
  250. long CommonCommands( void )
  251. {
  252.     CallHost( 5 );
  253.     return( (long)cmess.result );
  254. }
  255.  
  256.  
  257. /**************************************************************************
  258.  *
  259.  **************************************************************************/
  260. UBYTE ReadFile( char *path, UBYTE flags )
  261. {
  262.     cmess.arg1 = (ULONG)path;
  263.     cmess.arg2 = (ULONG)flags;          /* 1 = print File Not Found */
  264.     CallHost( 6 );
  265.     return( (UBYTE)cmess.result );      /* returns FALSE if File Not Found */
  266. }
  267.  
  268. /**************************************************************************
  269.  *        Sets the "Action" or "Where" field for the user's port          *
  270.  *      ** remember to retain and restore the previous z->DOING **        *
  271.  **************************************************************************/
  272. void SetDoing( char *what )
  273. {
  274.     cmess.arg1 = (ULONG)what;
  275.     CallHost( 7 );
  276. }
  277.  
  278.  
  279. /**************************************************************************
  280.  *Invokes the CNet editor according to user's preference of line or Visual*
  281.  **************************************************************************/
  282. void CallEditor( short max, short inlines )
  283. {
  284.     cmess.arg1 = (ULONG)max;    /* Maximum number of lines (250)*/
  285.     cmess.arg2 = (ULONG)inlines;    /* TRUE/FALSE use existing _edbuff? */
  286.     CallHost( 8 );
  287. }
  288.  
  289. /**************************************************************************
  290.  *             Read text file with MCI/graphic interpretation             *
  291.  **************************************************************************/
  292. UBYTE ReadGraphics( char *path, char flags )
  293. {
  294.     cmess.arg1 = (ULONG)path;
  295.     cmess.arg2 = (ULONG)flags;    /* 1 = print File Not Found    */
  296.     CallHost( 9 );
  297.     return( (UBYTE)cmess.result );        /* FALSE if File Not Found    */
  298. }
  299.  
  300. /**************************************************************************
  301.  *  Construct a date in CNet format - like that seen in the port titlebar *
  302.  **************************************************************************/
  303. void MakeDate( struct IsDate *date, char *output )
  304. {
  305.     cmess.arg1 = (ULONG)date;
  306.     cmess.arg2 = (ULONG)output;
  307.     CallHost( 10 );
  308. }
  309.  
  310.  
  311. /**************************************************************************
  312.  *                     Load userdata for account "id"                     *
  313.  **************************************************************************/
  314. UBYTE ReadAccount( short id, struct UserData *user )
  315. {
  316.     cmess.arg1 = (ULONG)id;
  317.     cmess.arg2 = (ULONG)user;
  318.     CallHost( 11 );
  319.     return( (UBYTE)cmess.result );
  320. }
  321.  
  322. /**************************************************************************
  323.  *           Saves an account after editing/changing attributes           *
  324.  **************************************************************************/
  325. UBYTE SaveAccount( struct UserData *user, short id )
  326. {
  327.     cmess.arg1 = (ULONG)user;
  328.     cmess.arg2 = (ULONG)id;
  329.     CallHost( 12 );
  330.     return( (UBYTE)cmess.result );
  331. }
  332.  
  333. /**************************************************************************
  334.  *         add charge amount "a" to charge schedule number "n"            *
  335.  **************************************************************************/
  336. UBYTE AddCharge( short n, short a )
  337. {
  338.     cmess.arg1 = (ULONG)n;
  339.     cmess.arg2 = (ULONG)a;
  340.     CallHost( 13 );
  341.     return( (UBYTE)cmess.result );
  342. }
  343.  
  344. /**************************************************************************
  345.  *
  346.  **************************************************************************/
  347. UBYTE CheckBalance( short n, short a )
  348. {
  349.     cmess.arg1 = (ULONG)n;
  350.     cmess.arg2 = (ULONG)a;
  351.     CallHost( 14 );
  352.     return( (UBYTE)cmess.result );
  353. }
  354.  
  355. /***************************************************************************
  356.  * Get text from user.  Results are placed in z.GBuffer[] array of strings *
  357.  * note that there are 16 lines MAX and each line may hold up to 80        *
  358.  * characters                                                              *
  359.  ***************************************************************************/
  360. int EnterText( char firstchar, short maxchars, short perline, short maxlines )
  361. {
  362.     cmess.arg1 = (ULONG)firstchar;
  363.     cmess.arg2 = (ULONG)maxchars;
  364.     cmess.arg3 = (ULONG)perline;
  365.     cmess.arg4 = (ULONG)maxlines;
  366.     CallHost( 15 );
  367.     return( (int)cmess.result );
  368. }
  369.  
  370. /**************************************************************************
  371.  *
  372.  **************************************************************************/
  373. long ConferenceWait( short a )
  374. {
  375.     cmess.arg1 = (ULONG) a;
  376.     CallHost( 16 );
  377.     return( (long)cmess.result );
  378. }
  379.  
  380.  
  381. /****************************************************************************
  382.  * Update the current time, load the user's bbstext translation, charges    *
  383.  * If the user has little time remaining, print "you have xx minutes left", *
  384.  * force Events to be checked for pending event execution..                 *
  385.  ****************************************************************************/
  386. void CheckChanges( void )
  387. {
  388.     CallHost( 17 );
  389. }
  390.  
  391.  
  392. /**************************************************************************
  393.  *      Converts a CNet access/range string to a packed LONG value        *
  394.  **************************************************************************/
  395. long ConvertAccess( char *s )
  396. {
  397.     cmess.arg1 = (ULONG)s;
  398.     CallHost( 18 );
  399.     return( (long)cmess.result );
  400. }
  401.  
  402.  
  403. /**************************************************************************
  404.  * return the number of bytes free on device specified by s               *
  405.  * if q==0, the result is displayed to the user by GetFree()              *
  406.  **************************************************************************/
  407. long GetFree( char *s, UBYTE q )
  408. {
  409.     cmess.arg1 = (ULONG)s;
  410.     cmess.arg2 = (ULONG)q;
  411.     CallHost( 19 );
  412.     return( (long)cmess.result );
  413. }
  414.  
  415. /**************************************************************************
  416.  *    Find an account based on account number, Handle or real name        *
  417.  *    This is the same routine that, if the user is not found, pops up    *
  418.  *    the mini-userlist for user choice.                                  *
  419.  **************************************************************************/
  420. short FindAccount( char *a, struct UserData *b, UBYTE quiet )
  421. {
  422.     /* a     = handle, name, account number to find
  423.     * b     = pointer to instance of struct UserData, where loaded account will
  424.     *         be placed.
  425.     * quiet = if account not found, do not print "could not find 'a'".
  426.     *
  427.     * also, you can set z.DoQuick=1 BEFORE calling FindAccount() if you do
  428.     * NOT want CNet to pop up the mini-handle/userlist.
  429.     */
  430.     
  431.     cmess.arg1 = (ULONG)a;
  432.     cmess.arg2 = (ULONG)b;
  433.     cmess.arg3 = (ULONG)quiet;
  434.     CallHost( 20 );
  435.     return( (short)cmess.result );
  436. }
  437.  
  438.  
  439. /**************************************************************************
  440.  *  Forces CNet to flush/check it's buffers and parse/update the keyboard *
  441.  *  buffers                                                               *
  442.  **************************************************************************/
  443. void CheckFlowControl( void )
  444. {
  445.     CallHost( 21 );
  446. }
  447.  
  448. /**************************************************************************
  449.  * list the contents of a directory (the user will be prompted for        *
  450.  * directory name).                                                       *
  451.  *                                                                        *
  452.  * options: a = allow selection of files to user's select list            *
  453.  *                                                                        *
  454.  *          b = 1: select and download immediately                        *
  455.  *              2: allow wildcard pattern                                 *
  456.  *                                                                        *
  457.  *          c = list files newer than the date specified by c             *
  458.  *              c is a properly filled out Cnet IsDate structure          *
  459.  **************************************************************************/
  460. long ListDir( UBYTE a, UBYTE b, struct IsDate *c )
  461. {
  462.     cmess.arg1 = (ULONG)a;
  463.     cmess.arg2 = (ULONG)b;
  464.     cmess.arg3 = (ULONG)c;
  465.     CallHost( 22 );
  466.     return( (long)cmess.result );
  467. }
  468.  
  469.  
  470. /**************************************************************************
  471.  * Read the next base/udbase message                                      *
  472.  **************************************************************************/
  473. UBYTE Rnext( void )
  474. {
  475.     CallHost( 24 );
  476.     return( (UBYTE)cmess.result );
  477. }
  478.  
  479. /***************************************************************************
  480.  * Parse the contents of z->InBuffer into z->pitems.  Parses up to numargs *
  481.  * items                                                                   *
  482.  ***************************************************************************/
  483. void ParseCommandLine( UBYTE numargs )
  484. {
  485.     cmess.arg1 = (ULONG)numargs;
  486.     CallHost( 25 );
  487. }
  488.  
  489.  
  490. /**************************************************************************
  491.  *  Takes the contents of z->InBuffer and searches for a matching command *
  492.  *  in menu "num" of BBSMENU.                                             *
  493.  **************************************************************************/
  494. short FindCommand( short num )
  495. {
  496.     cmess.arg1 = (ULONG) num;
  497.     CallHost( 26 );
  498.     return( (short)cmess.result );
  499. }
  500.  
  501. /**************************************************************************
  502.  * Open the filename specified by a, seek to position b in the file       *
  503.  * and display the contents of the file from point b to EOF               *
  504.  **************************************************************************/
  505. void ReadMessagePoint( char *a, long b )
  506. {
  507.     cmess.arg1 = (ULONG) a;
  508.     cmess.arg2 = (ULONG) b;
  509.     CallHost( 27 );
  510. }
  511.  
  512. /**************************************************************************
  513.  * Use the CNet editor to edit the file specified by "file"               *
  514.  **************************************************************************/
  515. void EditMessage( char *file )
  516. {
  517.     cmess.arg1 = (ULONG) file;
  518.     CallHost( 28 );
  519. }
  520.  
  521. /***************************************************************************
  522.  * Load the text from the file-handle given and insert it into the current *
  523.  * port's editor file                                                      *
  524.  ***************************************************************************/
  525. void LoadText( BPTR fh )
  526. {
  527.     cmess.arg1 = (ULONG) fh;
  528.     CallHost( 29 );
  529. }
  530.  
  531.  
  532. /**************************************************************************
  533.  *    1000000 mics = 1 second                                                *
  534.  **************************************************************************/
  535. char WaitForInput( long mics )
  536. {
  537.     cmess.arg1 = (ULONG) mics;
  538.     CallHost( 31 );
  539.     return( (char)cmess.result );
  540. }
  541.  
  542.  
  543. /**************************************************************************
  544.  *                       Select and download a file.                      *
  545.  *                                                                        *
  546.  * file  = full path/filename                                             *
  547.  *                                                                        *
  548.  * flags = 0 -> select without immediate download                         *
  549.  *       = 1 -> select and download immediately                           *
  550.  *                                                                        *
  551.  * flag values below are new for v4.11                                    *
  552.  *                                                                        *
  553.  *       = 2 -> delete file after downloading/no immediate download       *
  554.  *       = 3 -> delete file after downloading/download immediate.         *
  555.  **************************************************************************/
  556. UBYTE SelectAndDownload( char *file, UBYTE flags )
  557. {
  558.     cmess.arg1 = (ULONG)file;
  559.     cmess.arg2 = (ULONG)flags;
  560.     CallHost( 39 );
  561.     return( (UBYTE)cmess.result );
  562. }
  563.  
  564.  
  565. /**************************************************************************
  566.  * file: the ".vde" filename, without the ".vde"!                         *
  567.  * data: pointer to the structure you are going to edit                   *
  568.  * size: structure length in bytes                                        *
  569.  *                                                                        *
  570.  * returns: TRUE  if structure has been changed                           *
  571.  *          FALSE otherwise                                               *
  572.  **************************************************************************/
  573. short VisualDataEditor( char *file, void *data, long size )
  574. {
  575.     cmess.arg1 = (ULONG)file;
  576.     cmess.arg2 = (ULONG)data;
  577.     cmess.arg3 = (ULONG)size;
  578.     CallHost( 40 );
  579.     return( (short)cmess.result );
  580. }
  581.  
  582. /**************************************************************************
  583.  * In preparation for an ExtUpload, this function                         *
  584.  * sets the minimum number of free bytes to maintain on the    drive.        *
  585.  **************************************************************************/
  586. void ExtSetMinFree( long free )
  587. {
  588.     cmess.arg1 = (ULONG)free;
  589.     CallHost( 42 );
  590. }
  591.  
  592.  
  593. /**************************************************************************
  594.  * In preparation for an ExtDownload or an ExtUpload, this function       *
  595.  * sets the protocol to be used.  If you send NULL, it will allow the     *
  596.  * user to choose his OWN protocol.                                       *
  597.  *                                                                        *
  598.  * Otherwise, you may select 'a' to be the first letter of a valid        *
  599.  * system protocol (from BBSPROTO file), such as 'x', 'z', etc.           *
  600.  *                                                                        *
  601.  * TRUE will be returned if a protocol is selected and ready, FALSE       *
  602.  * if there is a problem.                                                 *
  603.  **************************************************************************/
  604. UBYTE ExtSetProtocol( char a )
  605. {
  606.     cmess.arg1 = (ULONG)a;
  607.     CallHost( 43 );
  608.     return( (UBYTE)cmess.result );
  609. }
  610.  
  611.  
  612.  
  613. /**************************************************************************
  614.  * This routine allows the user to download the SINGLE file specified     *
  615.  * by the FULL PATH 'args'.                                               *
  616.  *                                                                        *
  617.  *    Currently, NULL is always returned.                                    *
  618.  **************************************************************************/
  619. char *ExtDownload( char *args )
  620. {
  621.     cmess.arg1 = (ULONG)args;
  622.     CallHost( 44 );
  623.     return( (char *)cmess.result );
  624. }
  625.  
  626.  
  627. /**************************************************************************
  628.  * This routine allows the user to upload the file specified by           *
  629.  * 'args'.  The path for uploading will be taken from the path            *
  630.  * in 'args'.  If you do NOT specify a path, the file(s) will             *
  631.  * appear in the user's HOME directory.                                   *
  632.  *                                                                        *
  633.  * Note that with batch protocols like ZMODEM, the filename(s) are        *
  634.  * taken from the header packet information, and may NOT be the           *
  635.  * same as what you have requested the user upload.  For this reason,     *
  636.  * you should have uploads occur in a TEMP directory, and search that     *
  637.  * directory yourself for new files.                                      *
  638.  *                                                                        *
  639.  * Currently, NULL is always returned.                                    *
  640.  **************************************************************************/
  641. char *ExtUpload( char *args )
  642. {
  643.     cmess.arg1 = (ULONG)args;
  644.     CallHost( 45 );
  645.     return( (char *)cmess.result );
  646. }
  647.  
  648.  
  649. /**************************************************************************
  650.  * compare two strings and return result                                  *
  651.  *                                                                        *
  652.  * result: 0 if equal                                                     *
  653.  *        >0 if s is alphabetically "higher" than t                       *
  654.  *        <0 if t is alphabetically "higher" than s                       *
  655.  **************************************************************************/
  656. short compstra( char *s, char *t )
  657. {
  658.     for( ; tolower(*s) == tolower(*t); s++, t++)
  659.         if( !*s ) return 0;
  660.  
  661.     return (short)( tolower(*s)-tolower(*t) );
  662. }
  663.  
  664.  
  665. /**************************************************************************
  666.  * Print the prompt string passed as "a" and return the user's            *
  667.  * YES or NO equivalent result.  1=YES, 2=NO                              *
  668.  **************************************************************************/
  669. UBYTE PutQ( char *a )
  670. {
  671.     PutText( a );
  672.     return (UBYTE)(z->MCIcreg[0][0]=='1') ;
  673. }
  674.  
  675. /**************************************************************************
  676.  * Isn't it obvious enough? ;-)
  677.  **************************************************************************/
  678. void DoReturn( void )
  679. {
  680.     PutText("\n");
  681. }
  682.  
  683. /**************************************************************************
  684.  * Create the editor filename used for the current port and place it      *
  685.  * in the string array passed as "path"                                   *
  686.  **************************************************************************/
  687. void MakeEd( char *path )
  688. {
  689.     sprintf( path, "%s_edbuff%d", myp->gc.ZIPpath, z->InPort );
  690. }
  691.  
  692.  
  693. /**************************************************************************
  694.  * Delete the editor file                                                 *
  695.  **************************************************************************/
  696. void DeleteEd( void )
  697. {
  698.     char    filename[80];
  699.  
  700.     MakeEd    ( filename ) ;
  701.     DeleteFile( filename ) ;
  702. }
  703.  
  704. /**************************************************************************
  705.  * Open the file used for the editor and return the filehandle (BPTR)     *
  706.  **************************************************************************/
  707. BPTR OpenEd( long mode )
  708. {
  709.     char    filename[80];
  710.  
  711.     MakeEd( filename );
  712.  
  713.     return Open( filename, mode );
  714. }
  715.  
  716. /**************************************************************************
  717.  * insert the contents of the file belonging to filehandle "fp" into      *
  718.  * the current port's editor file                                         *
  719.  **************************************************************************/
  720. void PrepEditor( BPTR fp )
  721. {
  722.     BPTR    kp;
  723.     char    buff[100];
  724.  
  725.     if( fp ) {
  726.         if( kp = OpenEd( MODE_NEWFILE ) ) {
  727.             while( FGets( fp, buff, 82 ) && buff[0]!=26 )
  728.                    FPuts( kp, buff     ) ;
  729.  
  730.             Close( kp );
  731.         }
  732.     }
  733.     else    DeleteEd();
  734. }
  735.  
  736. /**************************************************************************
  737.  * Save the contents of the current port's editor file into the file      *
  738.  * belonging to filehandle "fp"                                           *
  739.  **************************************************************************/
  740. void SaveEditor( BPTR fp, UBYTE eof )
  741. {
  742.     BPTR    kp;
  743.     char    buff[100];
  744.  
  745.     if( kp = OpenEd( MODE_OLDFILE ) ) {
  746.         while( FGets( kp, buff, 82 ) && buff[0]!=26 )
  747.                FPuts( fp, buff     ) ;
  748.  
  749.         Close( kp );
  750.  
  751.         DeleteEd();
  752.     }
  753.  
  754.     if( eof ) FPuts( fp, "\032\n" );
  755. }
  756.  
  757.  
  758. BOOL IsAbort( void )
  759. {
  760. if (z->PrintFlags == 1)
  761.     {
  762.     PutText("[SKIP]");
  763.     return FALSE;
  764.     }
  765. if (z->PrintFlags > 1)
  766.     {
  767.     PutText("^C");
  768.    return FALSE;
  769.    }
  770. return TRUE;
  771. }
  772.